{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime\n",
    "class Diary():\n",
    "    def __init__(self, birthday, christmas):\n",
    "        self.birthday = birthday\n",
    "        self.christmas = christmas\n",
    "    \n",
    "    @staticmethod\n",
    "    def format_date(date):\n",
    "        return date.strftime('%d-%b-%y')\n",
    "    \n",
    "    def show_birthday(self):\n",
    "        return self.format_date(self.birthday)\n",
    "\n",
    "    def show_christmas(self):\n",
    "        return self.format_date(self.christmas)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "class CustomDiary(Diary):\n",
    "    def __init__(self, birthday, christmas, date_format):\n",
    "        self.date_format = date_format\n",
    "        super().__init__(birthday, christmas)\n",
    "    \n",
    "    def format_date(self, date):\n",
    "        return date.strftime(self.date_format)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "01-Jan-2018\n",
      "03/03/2018\n"
     ]
    }
   ],
   "source": [
    "first_diary = CustomDiary(datetime.date(2018,1,1), datetime.date(2018,3,3), '%d-%b-%Y')\n",
    "second_diary = CustomDiary(datetime.date(2018,1,1), datetime.date(2018,3,3), '%d/%m/%Y')\n",
    "\n",
    "print(first_diary.show_birthday())\n",
    "print(second_diary.show_christmas())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
